<page-header title="'Registry access'" breadcrumbs="[{label:'Registries', link:'kubernetes.registries'}, $ctrl.registry.Name, 'Access management']" reload="true"> </page-header>

<registry-details registry="$ctrl.registry" ng-if="$ctrl.registry"></registry-details>

<div class="row">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="user-x" title-text="Create access"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-3 col-lg-2 control-label text-left" style="padding-top: 0"> Select namespaces </label>
            <div class="col-sm-9 col-lg-4" style="margin-bottom: 15px">
              <span class="small text-muted" ng-if="!$ctrl.resourcePools.length"> No namespaces available. </span>

              <namespaces-selector
                ng-if="$ctrl.resourcePools.length"
                value="$ctrl.selectedResourcePools"
                namespaces="$ctrl.resourcePools"
                placeholder="'Select one or more namespaces'"
                on-change="($ctrl.onChangeResourcePools)"
              ></namespaces-selector>
            </div>
            <div class="col-sm-12 small text-muted vertical-center">
              <pr-icon icon="'alert-triangle'" mode="'warning'"></pr-icon>
              Adding this registry will expose the registry credentials to all users of this namespace.
            </div>
          </div>

          <!-- actions -->
          <div class="form-group">
            <div class="col-sm-12">
              <button
                type="submit"
                class="btn btn-primary btn-sm !ml-0"
                ng-disabled="$ctrl.selectedResourcePools.length === 0 || $ctrl.state.actionInProgress"
                ng-click="$ctrl.submit()"
                button-spinner="$ctrl.state.actionInProgress"
              >
                <span ng-hide="$ctrl.state.actionInProgress" class="vertical-center"><pr-icon icon="'plus'" size="'sm'"></pr-icon> Create access</span>
                <span ng-show="$ctrl.state.actionInProgress">Creating access...</span>
              </button>
            </div>
          </div>
          <!-- !actions -->
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<kube-registry-access-table dataset="$ctrl.savedResourcePools" on-remove="($ctrl.handleRemove)"></kube-registry-access-table>
